﻿<%@ Page Title="" Language="C#" MasterPageFile="~/administrator/backend.Master" AutoEventWireup="true"
    CodeBehind="course-add.aspx.cs" Inherits="VQWEB.administrator.english.courses.course_add" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Content_backend" runat="server">
    <form id="frmObjects" action="" >
    
    </form>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Script_backend" runat="server">

 <script type="text/javascript">
     ShowToolBar("edit");
     var url_ashx = "/admin/english/course/handler";
     var url_input = '<%=ResolveUrl("~/administrator/templates/input.tpl") %>';

     $(document).ready(function () {
         if (CheckAtionInPath("add")) {
             loadform(0, "", "", false);
         }
         else if (CheckAtionInPath("edit")) {
             $.get(url_ashx, { view_course: "view_course", Id: GetId() }, function (data) {
                 var obj = $.parseJSON(data);
                 loadform(obj.id, obj.code, obj.title, obj.active);
             });
         }

     });

     function loadform(id, code ,title, active) {
         $.jqoteload(url_input, function (tmpl) {

             $("#frmObjects").single("hidden", "course_id", id, null, null, tmpl.input_tpl);
             $("#frmObjects").single("text", "course_code", title, "Code:", null, tmpl.input_tpl);
             $("#frmObjects").single("textarea", "course_title", content, "Title:", null, tmpl.input_tpl);
             $("#frmObjects").single("checkbox", "course_active", true, "Active", active, tmpl.input_tpl);
         });

     }


     $(document).on("click", "#btnCancel", function () {
         window.location = "/admin/english/course/list";
     });
     $(document).on("click", "#btnSave", function () {
         var arr = $("#frmObjects").serializeObject();
         $.post(url_ashx, { add_course: window.escape(arr) }, function (data) {
             alert(data);
             window.location = "/admin/english/course/list";
         });
     });
    </script>
</asp:Content>
